package com.jzo2o.foundations.controller.consumer;

import com.jzo2o.foundations.model.dto.response.ServeAggregationSimpleResDTO;
import com.jzo2o.foundations.model.dto.response.ServeAggregationTypeSimpleResDTO;
import com.jzo2o.foundations.model.dto.response.ServeCategoryResDTO;
import com.jzo2o.foundations.service.HomeService;
import com.jzo2o.foundations.service.IServeTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Validated
@RestController("consumerServeController")
@RequestMapping("/customer/serve")
@Api(tags = "用户端 - 首页服务查询接口")
public class FirstPageServeController {
    @Resource
    private HomeService homeService;

    @Autowired
    private IServeTypeService serveTypeService;
    /**
     * 首页服务列表
     * @param regionId
     * @return
     */
    @ApiOperation("首页服务列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "regionId", value = "区域id", required = true, dataTypeClass = Long.class)
    })
    @GetMapping("/firstPageServeList")
    public List<ServeCategoryResDTO> firstPageServeList(@RequestParam("regionId") Long regionId) {
        return homeService.firstPageServeList(regionId);
    }

    /**
     * 服务类型列表
     * @param regionId
     * @return
     */
    @GetMapping("/serveTypeList")
    @ApiOperation("服务类型列表")
    public List<ServeAggregationTypeSimpleResDTO> serveTypeList(@RequestParam("regionId") Long regionId){
        return homeService.serveTypeList(regionId);
    }

    /**
     * 首页热门服务列表
     * @param regionId
     * @return
     */
    @GetMapping("/hotServeList")
    @ApiOperation("首页热门服务列表")
    public List<ServeAggregationSimpleResDTO> hotServeList(@RequestParam("regionId") Long regionId){
        return homeService.hotServeList(regionId);
    }

    /**
     * 根据id查询服务
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    @ApiOperation("根据id查询服务")
    public ServeAggregationSimpleResDTO getServeById(@PathVariable Long id){
        return homeService.getServeById(id);
    }
}